background = Image.load("background.png", VRAM)

game = {}
game.start = {}
game.start.round = {}
game.round = 0
game.status = 1

 -- -- -- -- -- -- -- -- -- -- --
 -- -- CALL OTHER LUA FILES-- -- 
 -- -- -- -- -- -- -- -- -- -- -- 
 
 dofile("hero/hero.lua") -- HERO
 dofile("spells/spells.lua") -- SPELLS: This file contains the handling of all spells
 dofile("enemies/enemies.lua") -- ENEMIES: This file contains the whole handling of the enemies
 dofile("objects/objects.lua") -- OBJECTS: This file contains a function which creats an area which the hero can't pass
 dofile("timer.lua")
 dofile("menu/skillpoints.lua") -- OBJECTS
 dofile("compare.lua")
 
 hero.load()

-- -- -- -- -- -- -- -- -- --
-- -- Rounds -- -- -- -- -- ======> only for testing the game. Will be deleted.
-- -- -- -- -- -- -- -- -- --

function game.rounds()
  if enemy.max < 1 then 
    game.round = game.round + 1 
    game.start.round(game.round)
  end
end

function game.start.round(max)
	for i= 1, max do
		newredfish()
		newredfish()
		newredfish()
	end
end

-- -- -- -- -- -- -- -- -- --
-- -- MAINLOOP -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- 



while not Keys.newPress.Start do
	Controls.read()
	startDrawing()
	clock.run()
	
	screen.blit(SCREEN_DOWN,0,0, background)
	
	
	if game.status == 1 then 
		hero.main()
		game.rounds()
		if enemy.max > 0 then enemy.run() end 
	elseif game.status == 2 then
		menu.sp.screen()
	end
	
	screen.print(SCREEN_UP, 0,30, "Leben :"..hero.hp)
	screen.print(SCREEN_UP, 0,50, "Mana: "..hero.mana)
	screen.print(SCREEN_UP, 0,70, NB_FPS) 
	screen.print(SCREEN_UP, 0,80, hero.class)
	screen.print(SCREEN_UP, 0,90, hero.level)
	screen.print(SCREEN_UP, 0,100, hero.save.status.life)
	
	stopDrawing()	
end

background = nil
spimg = nil
hero.savegame()

